﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using easyList.Options;
using easyList.Options.Entities;

namespace easyList
{
    public partial class OptionWindow : Form
    {
        public OptionWindow()
        {
            InitializeComponent();
        }

        private void allowedFormatsInput_MouseEnter(object sender, EventArgs e)
        {
            toolTip1.Show("Please insert valid formats separated by semicolon ; \nExample: mkv;avi", this.allowedFormatsInput, 5000);
        }

      

        private void ignoredFormatsInput_MouseEnter(object sender, EventArgs e)
        {
            toolTip1.Show("Please insert valid formats separated by semicolon ; \nExample: mkv;avi", this.ignoredFormatsInput, 5000);
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            discardChanges();
            this.Close();
        }

        private void OKButton_Click(object sender, EventArgs e)
        {
            commitChanges();
            this.Close();
        }


        private void discardChanges()
        {


        }

        private void commitChanges()
        {
            //load the option manager
            OptionManager manager = OptionManager.Instance;

            List<Option> options = new List<Option>();
            options.Add(new Option("allowedFormatsEnabled", allowedFormatsCheckbox.Checked));
            options.Add(new Option("ignoredFormatsEnabled", ignoredFormatsCheckbox.Checked));
            options.Add(new Option("allowedFormats", allowedFormatsInput.Text));
            options.Add(new Option("ignoredFormats", ignoredFormatsInput.Text));

            manager.setOptions(options);
  
        }

    }
}
